package com.dcy.workflow.dao;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dcy.common.base.dao.DcyBaseDao;
import com.dcy.common.model.PageModel;
import com.dcy.workflow.mapper.FlowNodeMapper;
import com.dcy.workflow.model.FlowNode;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author dcy
 * @since 2022-11-09
 */
@Service
public class FlowNodeDao extends DcyBaseDao<FlowNodeMapper, FlowNode> {

    /**
     * 获取表格数据
     *
     * @param flowNode
     * @param pageModel
     * @return
     */
    public IPage<FlowNode> pageListByEntity(FlowNode flowNode, PageModel pageModel) {
        LambdaQueryWrapper<FlowNode> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.like(StrUtil.isNotBlank(flowNode.getProcDefId()), FlowNode::getProcDefId, flowNode.getProcDefId());
        queryWrapper.like(StrUtil.isNotBlank(flowNode.getFlowId()), FlowNode::getFlowId, flowNode.getFlowId());
        queryWrapper.like(StrUtil.isNotBlank(flowNode.getFlowName()), FlowNode::getFlowName, flowNode.getFlowName());
        queryWrapper.like(StrUtil.isNotBlank(flowNode.getFlowType()), FlowNode::getFlowType, flowNode.getFlowType());
        return super.pageList(pageModel, queryWrapper);
    }

}
